<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商家优惠券派发概览</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">

               *{ <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">商家ID</label>
                            <div class="layui-input-block" style="width: 200px;">
                                <input class="layui-input" name="merchantId" placeholder="请输入商家ID" autocomplete="off">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">商家名称</label>
                            <div class="layui-input-block" style="width: 200px;">
                                <input class="layui-input" name="name" placeholder="请输入商家名称" autocomplete="off">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"> 搜索</i>
                            </button>
                        </div>
                    </div>
                </div>}*

                <table class="layui-hide" id="test-table-reload" lay-filter="test-table-reload"></table>

                <script type="text/html" id="test-table-reload-barDemo">
                    <a class="layui-btn layui-btn-normal layui-btn-xs #{if !toolsUtils.checkBtn('/merchant/merchantCouponStat')} layui-hide #{/if}" lay-event="dataList"><i class="layui-icon layui-icon-chart-screen"></i>数据报表</a>
                    <a class="layui-btn layui-btn-normal layui-btn-xs #{if !toolsUtils.checkBtn('/merchant/merchantCouponDetails')} layui-hide #{/if}" lay-event="details"><i class="layui-icon layui-icon-read"></i>明细</a>
                </script>
            </div>
        </div>
    </div>
</div>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'utils', 'form'], function () {
        var $ = layui.$,
                table = layui.table,
                form = layui.form,
                admin = layui.admin;

        //监听搜索
        form.on("submit(LAY-search)", function (data) {
            var field = data.field;

            //执行重载
            table.reload('test-table-reload', {
                where: field
            });
        });

        //方法级渲染
        table.render({
            elem: '#test-table-reload'
            , url: "/merchant/getAllMerchantCouponList"
            , toolbar: '#test-table-reload-toolbar'
            , defaultToolbar: ['filter']
            , cellMinWidth: 80
            , cols: [[
                {field: 'merchantId', title: '商家ID', fixed: true}
                , {field: 'merchantName', title: '商家名称', width: 260}
                , {field: 'couponName', title: '优惠券名称', width: 260}
                , {field: 'dispatchCount', title: '领取数量', sort: true}
                , {field: 'donateCount', title: '赠送数量', sort: true}
                , {field: 'usedCount', title: '使用数量', sort: true}
                , {field: 'remainCount', title: '剩余数量', sort: true}
                , {fixed: 'right', title: '操作', toolbar: '#test-table-reload-barDemo', width: 200}
            ]]
            , page: true
            , height: 522
        });

        //监听行工具事件
        table.on('tool(test-table-reload)', function (obj) {
            var data = obj.data;
            if (obj.event === 'details') {
                parent.layui.index.openTabsPage("/merchant/merchantCouponDetails?couponId=" + data.couponId + "&merchantName=" + data.merchantName + "&couponName=" + data.couponName, "商家优惠券明细");
            } else if (obj.event === 'dataList') {
                parent.layui.index.openTabsPage("/merchant/merchantCouponStat?couponId=" + data.couponId + "&merchantName=" + data.merchantName + "&couponName=" + data.couponName, "商家优惠券数据报表");
            }
        });

    });
</script>
</body>
</html>